<?php
namespace Plugin\Organization\Schema;

use Plugin\Organization\Model\RdOrganizeUser;
use Hyperf\Swagger\Annotation\Property;
use Hyperf\Swagger\Annotation\Schema;

/**
 * 工区账号公司关联表
 */
#[Schema(title: 'RdOrganizeUserSchema')]
class RdOrganizeUserSchema implements \JsonSerializable
{
    #[Property(property: 'id', title: '主键', type: 'bigint')]
    public string $id;

    #[Property(property: 'user_id', title: '用户id', type: 'bigint')]
    public string $user_id;

    #[Property(property: 'enterprise_id', title: '企业id', type: 'bigint')]
    public string $enterprise_id;

    #[Property(property: 'wechat_openid', title: '微信openid，用于微信登录', type: 'varchar')]
    public string $wechat_openid;

    #[Property(property: 'extra_data', title: '额外数据，存储各平台特有的用户信息', type: 'json')]
    public string $extra_data;

    #[Property(property: 'department', title: '部门', type: 'varchar')]
    public string $department;

    #[Property(property: 'position', title: '职位', type: 'varchar')]
    public string $position;

    #[Property(property: 'created_at', title: 'created_at', type: 'timestamp')]
    public string $created_at;

    #[Property(property: 'updated_at', title: 'updated_at', type: 'timestamp')]
    public string $updated_at;

    #[Property(property: 'created_by', title: '创建者', type: 'bigint')]
    public string $created_by;

    #[Property(property: 'updated_by', title: '更新者', type: 'bigint')]
    public string $updated_by;

    #[Property(property: 'remark', title: '备注', type: 'varchar')]
    public string $remark;




    public function __construct(RdOrganizeUser $model)
    {
       $this->id = $model->id;
       $this->user_id = $model->user_id;
       $this->enterprise_id = $model->enterprise_id;
       $this->wechat_openid = $model->wechat_openid;
       $this->extra_data = $model->extra_data;
       $this->department = $model->department;
       $this->position = $model->position;
       $this->created_at = $model->created_at;
       $this->updated_at = $model->updated_at;
       $this->created_by = $model->created_by;
       $this->updated_by = $model->updated_by;
       $this->remark = $model->remark;

    }

    public function jsonSerialize(): array
    {
        return [
            'id' => $this->id,
            'user_id' => $this->user_id,
            'enterprise_id' => $this->enterprise_id,
            'wechat_openid' => $this->wechat_openid,
            'extra_data' => $this->extra_data,
            'department' => $this->department,
            'position' => $this->position,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at,
            'created_by' => $this->created_by,
            'updated_by' => $this->updated_by,
            'remark' => $this->remark
        ];
    }
}